from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

class DownloadLinkSchema(BaseModel):
    id: Optional[int]
    url: str
    link_type: str
    file_format: str

    class Config:
        orm_mode = True

class SoftwareCreateSchema(BaseModel):
    name: str
    version: Optional[str]
    description: Optional[str]
    category: Optional[str]
    license: Optional[str]
    source: Optional[str]
    links: List[DownloadLinkSchema] = []

class SoftwareSchema(SoftwareCreateSchema):
    id: int
    update_time: datetime

    class Config:
        orm_mode = True

class FeedbackCreateSchema(BaseModel):
    content: str
    contact: Optional[str]
    captcha_token: str

class FeedbackSchema(BaseModel):
    id: int
    content: str
    contact: Optional[str]
    create_time: datetime

    class Config:
        orm_mode = True
